﻿$("#passwordChange").click(function () {
    $.popupDiv({
        title: "修改我的密码", url: "http://i.zhaopin.com/usermaster/UsermasterManage/passwordchange", success: function () {

            $("#passwordOld").validate({
                rules: [{
                    text: "请输入6－20位密码",
                    rule: "password"
                }],
                validText: "",
                tipTagId: "passwordOld_warn"
            });
            $("#password1").validate({
                rules: [{
                    text: "请输入6－20位密码",
                    rule: "password"
                }],
                validText: "",
                tipTagId: "password1_warn"
            });
            $("#password2").validate({
                rules: [{
                    text: "请再次输入6－20位密码",
                    rule: "password"
                }, {
                    text: "两次输入的密码不一致",
                    rule: function (s) {
                        if ($("#password1").val() == $("#password2").val()) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                }],
                validText: "",
                tipTagId: "password2_warn"
            });


        },
        buttons: {
            "保 存": function () {
                $.validate("frmPassword", function () {
                    var param = "oldpassword=" + $("#passwordOld").val() + "&newpassword=" + $("#password1").val() + "&newpasswordrepeate=" + $("#password2").val();
                    $.ajax({
                        url: "http://i.zhaopin.com/usermaster/UsermasterManage/PasswordChangeSave",
                        dataType: 'jsonp',
                        jsonp: 'jsoncallback',
                        data: param,
                        success: function (result) {
                            $.popupDiv({
                                title: "修改我的密码",
                                msg: result,
                                buttons: {
                                    "关 闭": function () {
                                        $.popupClose();
                                    }
                                }
                            });
                        },
                        error: function () {
                            $.popupDiv({
                                title: "修改我的密码",
                                msg: "操作异常，请稍后重试！",
                                buttons: {
                                    "关 闭": function () {
                                        $.popupClose();
                                    }
                                }
                            });
                        }
                    });
                    //$.post("http://i.zhaopin.com/usermaster/UsermasterManage/PasswordChangeSave", param, function (data) {
                    //    $.popupDiv({
                    //        title: "修改我的密码",
                    //        msg: data,
                    //        buttons: {
                    //            "关 闭": function () {
                    //                $.popupClose();
                    //            }
                    //        }
                    //    });
                    //});
                });
            }, "取 消": function () {
                $.popupClose();
            }
        }, width: 414
    });
    return false;
});





$("#edmSubscribe").click(edmSub);

function edmSub() {
    var flag_lists = "", flag_edm_1 = "", flag_edm_2 = "", flag_post = false;
    $.popupDiv({
        title: "邮件服务", url: "http://i.zhaopin.com/usermaster/UsermasterManage/edmSubscribe", success: function () {
            if ($("#status_lists").val() == "1") {
                $("#lists_1").attr("checked", "checked");
            }
            else {
                $("#lists_0").attr("checked", "checked");
            }
            if ($("#status_edm_1").val() == "1") {
                $("#edm_1_1").attr("checked", "checked");
            } else {
                $("#edm_1_0").attr("checked", "checked");
            }
            if ($("#status_edm_2").val() == "1") {
                $("#edm_2_1").attr("checked", "checked");
            } else {
                $("#edm_2_0").attr("checked", "checked");
            }
        },
        buttons: {
            "保 存": function () {
                if ($("#status_lists").val() == "1" && $("#lists_0").attr("checked") == "checked") {
                    flag_lists = "N";
                    flag_post = true;
                } else if ($("#status_lists").val() != "1" && $("#lists_1").attr("checked") == "checked") {
                    flag_lists = "Y";
                    flag_post = true;
                }
                if ($("#status_edm_1").val() == "1" && $("#edm_1_0").attr("checked") == "checked") {
                    flag_edm_1 = 0;
                    flag_post = true;
                } else if ($("#status_edm_1").val() != "1" && $("#edm_1_1").attr("checked") == "checked") {
                    flag_edm_1 = 1;
                    flag_post = true;
                }
                if ($("#status_edm_2").val() == "1" && $("#edm_2_0").attr("checked") == "checked") {
                    flag_edm_2 = 0;
                    flag_post = true;
                } else if ($("#status_edm_2").val() != "1" && $("#edm_2_1").attr("checked") == "checked") {
                    flag_edm_2 = 1;
                    flag_post = true;
                }
                if (flag_post) {
                    $.ajax({
                        url: "http://i.zhaopin.com/usermaster/UsermasterManage/edmSubscribeSave",
                        data: { "lists": flag_lists, "edm_1": flag_edm_1, "edm_2": flag_edm_2 },
                        success: function (res) {
                            $.popupDiv({
                                title: "邮件服务",
                                msg: "您的设置保存成功",
                                buttons: { "关 闭": function () { $.popupClose(); }, "返 回": function () { $.popupClose(); edmSub(); } }
                            });
                        },
                        error: function () {
                            $.popupDiv({
                                title: "邮件服务",
                                msg: "抱歉，保存失败，请稍后重试",
                                buttons: { "关 闭": function () { $.popupClose(); }, "返 回": function () { $.popupClose(); edmSub(); } }
                            });
                        }
                    });
                } else {
                    $.popupDiv({
                        title: "邮件服务",
                        msg: "您的设置保存成功",
                        buttons: { "关 闭": function () { $.popupClose(); }, "返 回": function () { $.popupClose(); edmSub(); } }
                    });
                }

            }
			, "取 消": function () { $.popupClose(); }
        }, width: 520
    });
    return false;
};

$(".navBody1").click(function () {
    var _top = $(this).offset().top,
        _left = $(this).offset().left;
    $(".nav_listmain").css({ "left": _left - 6 + "px", "top": _top - 1 + "px" }).show()
});
$(".nav_listmain").mouseleave(function () {
    $(".nav_listmain").hide();
})
$(".navBody2").click(function () {
    var _top = $(this).offset().top,
        _left = $(this).offset().left;
    $(".nav_listmain_1").css({ "left": _left - 6 + "px", "top": _top - 1 + "px" }).show()
});
$(".nav_listmain_1").mouseleave(function () {
    $(".nav_listmain_1").hide();
})